/*
 *  This file is part of WWWPal.
 *
 *  Copyright (C) 2003  Dr. John Punin, Department of Computer Science
 *  Rensselaer Polytechnic Institute
 *
 *  WWWPal is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  WWWPal is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 *  This file is part of WWWPal.
 *
 *  Copyright (C) 2003  Dr. John Punin, Department of Computer Science
 *  Rensselaer Polytechnic Institute
 *
 *  WWWPal is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  WWWPal is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#include "LOGR_keywords.h"

WebKeywordPtr
new_web_keyword_node(void)
{
  WebKeywordPtr kn = (WebKeywordPtr)calloc(1, sizeof(WebKeywordStruct));
  if(!kn) {
      fprintf(stderr,"Out of Memory new_web_keyword_node\n");
      abort();
  }
  return kn;
}

WebKeywordPtr
new_web_keyword_node2(char *keyword)
{
  WebKeywordPtr kn = new_web_keyword_node();
  GRStrAllocCopy(kn->keyword,keyword);
  return kn;
}

void
delete_web_keyword_node(WebKeywordPtr kn)
{	
    if(!kn) return;
    if(kn->keyword) {
	free(kn->keyword); kn->keyword = NULL;
    }
    free(kn); kn = NULL;
}

void
LOGR_set_keyword(WebKeywordPtr kn, char *keyword)
{
    if(!kn)
	return;
    GRStrAllocCopy(kn->keyword,keyword);	
}

char *
LOGR_get_keyword(WebKeywordPtr kn)
{
    if(!kn)
	return NULL;
    return kn->keyword;
}

void
LOGR_set_total_count(WebKeywordPtr kn, int n)
{
    if(!kn)
	return;
    kn->tcount = n;
}

void
LOGR_inc_total_count(WebKeywordPtr kn)
{
    if(!kn)
	return;
    kn->tcount++;

}

int
LOGR_get_total_count(WebKeywordPtr kn)
{
    if(!kn)
	return -1;
    return kn->tcount;
}

void
LOGR_set_search_engine_count(WebKeywordPtr kn, int n, int i)
{
    if(!kn)
	return;

    if(i < 0 && i >= NSEARCHENGINE)
	return;

    kn->ncount[i] = n;
}

void
LOGR_inc_search_engine_count(WebKeywordPtr kn, int i)
{
    if(!kn)
	return;

    if(i < 0 && i >= NSEARCHENGINE)
	return;

    (kn->ncount[i])++;
}

int
LOGR_get_search_engine_count(WebKeywordPtr kn, int i)
{
    if(!kn)
	return -1;

    if(i < 0 && i >= NSEARCHENGINE)
	return -1;

    return (kn->ncount[i]);
}

int
LOGR_is_total_count_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->tcount < v->tcount);
}

int
LOGR_is_total_count_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->tcount > v->tcount);
}

int
LOGR_is_se_count1_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[1] < v->ncount[1]);
}

int
LOGR_is_se_count1_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[1] > v->ncount[1]);
}

int
LOGR_is_se_count2_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[2] < v->ncount[2]);
}

int
LOGR_is_se_count2_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[2] > v->ncount[2]);
}

int
LOGR_is_se_count3_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[3] < v->ncount[3]);
}

int
LOGR_is_se_count3_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[3] > v->ncount[3]);
}

int
LOGR_is_se_count4_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[4] < v->ncount[4]);
}

int
LOGR_is_se_count4_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[4] > v->ncount[4]);
}

int
LOGR_is_se_count5_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[5] < v->ncount[5]);
}

int
LOGR_is_se_count5_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[5] > v->ncount[5]);
}

int
LOGR_is_se_count6_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[6] < v->ncount[6]);
}

int
LOGR_is_se_count6_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[6] > v->ncount[6]);
}

int
LOGR_is_se_count7_keyword_lower(WebKeywordPtr u, WebKeywordPtr v)
{
  return (u->ncount[7] < v->ncount[7]);
}

int
LOGR_is_se_count7_keyword_bigger(WebKeywordPtr u,WebKeywordPtr v)
{
  return(u->ncount[7] > v->ncount[7]);
}




